﻿using System;
using System.IO;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Xml.Serialization;


namespace MainScene
{
    [Serializable]
    [XmlInclude(typeof(ResourcesData))]
    [XmlInclude(typeof(BoxData))]
    [XmlInclude(typeof(UnitData))]
    [XmlInclude(typeof(DoorData))]
    [XmlInclude(typeof(AreaData))]
    [XmlInclude(typeof(CameraData))]
    [XmlInclude(typeof(PathNodeData))]
    [XmlInclude(typeof(SpawnPointData))]
    [XmlInclude(typeof(SpawnPointExData))]
    [XmlInclude(typeof(SimpleCameraTrackData))]
    [XmlInclude(typeof(LevelMapRangeData))]
    [XmlInclude(typeof(LevelPlayerSettingData))]
    [XmlInclude(typeof(DamageAreaData))]
    [XmlInclude(typeof(DamageAreaSpawnData))]
    [XmlInclude(typeof(ScanningUnitData))]
    [TypeConverterAttribute(typeof(ExpandableObjectConverter))]
    public class ObjectData
    {
        [XmlIgnore]
        public int objectType;
        [XmlAttribute("objectId")]
        public string objectId;
        [XmlAttribute("visible")]
        public bool visible;
        [XmlAttribute("posX")]
        public float posX;
        [XmlAttribute("posY")]
        public float posY;
        [XmlAttribute("posZ")]
        public float posZ;

        //forward 偏移
        [XmlAttribute("rotX")]
        public float rotX;
        [XmlAttribute("rotY")]
        public float rotY;
        [XmlAttribute("rotZ")]
        public float rotZ;

        [XmlAttribute("scaleX")]
        public float scaleX = 1;
        [XmlAttribute("scaleY")]
        public float scaleY = 1;
        [XmlAttribute("scaleZ")]
        public float scaleZ = 1;
        //角度偏移
        public void Init(string objectId, bool visible)
        {
            this.objectId = objectId;
            this.visible = visible;
        }

        public void SetPostion(UnityEngine.Vector3 pos)
        {
            posX = pos.x;
            posY = pos.y;
            posZ = pos.z;
        }
        public void SetPosition(float x, float y, float z)
        {
            posX = x;
            posY = y;
            posZ = z;
        }

        public void SetRotation(UnityEngine.Vector3 farward, UnityEngine.Vector3 scale)
        {
            rotX = farward.x;
            rotY = farward.y;
            rotZ = farward.z;
            scaleX = scale.x;
            scaleY = scale.y;
            scaleZ = scale.z;
        }
        public void SetRotation(float x, float y, float z, float scaleX, float scaleY, float scaleZ)
        {
            rotX = x;
            rotY = y;
            rotZ = z;
            this.scaleX = scaleX;
            this.scaleY = scaleY;
            this.scaleZ = scaleZ;
        }


    }
}


/// <summary>
/// Unit AI 类型
/// 中立怪 ai 逻辑通过配置区域事件触发 对话框实现
/// 防御型怪的 ai 逻辑 通过配区域事件触发 和控制个体行为
/// </summary>
public enum SceneUnitAI
{
    FixStand,
    AutoCruiser,
    CruiserAndLoop,
    OneLine,
}

/// <summary>
/// 场景物体类型
/// </summary>
public enum SceneObjType
{
    Unit,
    Door,//墙
    Resources,//采集资源
    Box, // 宝箱
    Area, //触发区域
    Camera,//摄像机
    PathNode,// 路径点

    SpawnPoint,
    MonsterCave,
    MonsterCaveEx,
    SpawnPointEx,

    SimpleCameraTrack,//相机路径
    LevelMapRange, //通用配置
    LevelPlayerSettingData,
    DamageArea,//伤害区域
    DamageAreaSpawn,//伤害区域生成点
    ScanningUnit,//扫描物件  
}

public enum TriggerMsgId
{
    Active,
    Destroy,
    Enter,
    Stay,
    Exit,
}
/// <summary>
/// 命令条件触发类型
/// </summary>
public enum EvtConditionType
{
    OnAction,
    OnArea,
    //OnAwaysArea,
    OnEffect,
    OnWndMsg,
    OnSceneEvt,
    OnTriggerEvt,
    OnUnitDead,
    OnHoldRole,  //发现主角
    OnCatchRole, //撞到主角
    OnGameTrigger,
    OnUnitClick,//点击场景物件
    OnAreaMutil,//区域多人触发
    OnScanningNum,// 指定Unit 被扫描到指定次数
    OnBeScanning,//被指定ScanningUnit 扫描到

}


/// <summary>
/// 场景的事件类型
/// </summary>
public enum EvtCommandType
{
    /// <summary>播放动作，(采集 , 咆哮) </summary>
    ActionCommand,
    /// <summary>设置物体显隐 </summary>
    SetObjectVisible,
    /// <summary>设置 个体自动寻路到某个点 </summary>
    SetUnitAutoMove,
    //出生点 -- 波数 ，结束开启 关卡墙
    /// <summary> 开启一次战斗</summary>
    BeginOneFight,
    PlayEffect,
    /// <summary> 结束一场战斗</summary>
    //EndOneFight, 结束删除 生成的怪 ，全部完成抛出事件

    /// <summary> 设置转向</summary>
    SetOrientation,
    /// <summary> 设置位置</summary>
    SetPosition,
    /// <summary> 将当前摄像机切换到固定移动模式</summary>
    ChangeToFixCamera,
    //切换到目标的前方偏移量
    ChangeToFixTargetOffset,
    /// <summary> 设置摄像机跟随 (设置回主角跟随) </summary>
    ChangeCameraTarget,
    /// <summary> 设置 Unit AI行为( 主角Idle 状态 , 无法控制 ; 可以自由控制  ) </summary>
    ChangeUnitAI,
    /// <summary>设置 相机FOV </summary>
    SetFieldOfView,
    /// <summary>显示配置的 事件选项对话 </summary>
    ShowTalk,
    PlayPlot,

    ActiveTrigger,
    SetUnitAIActive,
    SendWndMsg,
    DelateStory,

    OperateSceneUnit,
    OperateUnitBubble,
    SceneNPCBattleFight,
    HideLoadingPanel,
    SliderCell,
    JumpCell,
    RaidEndCell,
    PlaySceneEffect,
    AnimatorState,
    ChangeUICondtion,
    HideSceneGameObject,
    RotateSceneObj,
    PlayEffectBone,
}